package io.renren.modules.medical.controller;

import io.renren.common.result.Result;
import io.renren.common.utils.PageUtils;
import io.renren.modules.medical.entity.QuestionnaireSurveyEntity;
import io.renren.modules.medical.service.QuestionnaireSurveyService;
import io.renren.modules.medical.vo.weixinVo.ApiQuestionnaireListVo;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

/**
 * 问卷调查接口
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/medical/questionnaire/survey")
public class QuestionnaireSurveyController {

    private final QuestionnaireSurveyService questionnaireSurveyService;
    /**
     * 列表
     */
    @RequiresPermissions("questionnaire:survey:list")
    @GetMapping("/list")
    public Result<PageUtils> list(@RequestParam Map<String, Object> params){
        PageUtils page = questionnaireSurveyService.queryPage(params);

        return Result.success(page);
    }

    /**
     * 获取到历史记录：historyList
     */
    @RequiresPermissions("questionnaire:survey:historyList")
    @GetMapping("/historyList/{patientInfoId}")
    public Result<List<ApiQuestionnaireListVo>> historyList(@PathVariable("patientInfoId") Long patientInfoId){
        List<ApiQuestionnaireListVo> historyList = questionnaireSurveyService.historyList(patientInfoId);
        return Result.success(historyList);
    }

    /**
     * 获取评估详情
     */
    @RequiresPermissions("questionnaire:survey:info")
    @GetMapping("/info/{id}")
    public Result<QuestionnaireSurveyEntity> info(@PathVariable Long id){
        QuestionnaireSurveyEntity questionnaireSurveyEntity = questionnaireSurveyService.getById(id);
        return Result.success(questionnaireSurveyEntity);
    }

}
